project(dmis-utilities)
cmake_minimum_required( VERSION 2.8 )

set ( CMAKE_BUILD_TYPE Debug )
set ( EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/../../bin )
if( UNIX )
  add_definitions( -Wall -Wno-unused-function -Wno-write-strings )
endif()
include_directories ( ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )

# change the following line to true if you have made changes to reformatDmis.lex
# and need to regenerate reformatDmis.cc
set( REBUILD_PARSER false )

FIND_PACKAGE(FLEX)

if( FLEX_FOUND AND REBUILD_PARSER )
  message( "Will rebuild generated parser file with Flex." )
  FLEX_TARGET( reformatDmis reformatDmis.lex ${PROJECT_BINARY_DIR}/reformatDmis.cc )
  message( "Files generated by FLEX: ${FLEX_reformatDmis_OUTPUTS}" )
else()
  if( REBUILD_PARSER )
    message( FATAL_ERROR "Error, tried to regenerate parser but cannot find Flex!")
  else()
    message( "Will not run Flex (this is normal)." )
    #not regenerating, so set these vars to the names of the already-generated files
    set( FLEX_reformatDmis_OUTPUTS ${CMAKE_SOURCE_DIR}/reformatDmis.cc )
  endif()
endif()

add_executable( reformatDmis ${FLEX_reformatDmis_OUTPUTS} )

add_executable( check4Lines check4Lines.cc )

add_executable( removeLines removeLines.cc )

if( NOT UNIX )
  #only useful on windows
  add_executable( removeLinefeed removeLinefeed.cc )
endif()
